package com.jacklin.entity;


import com.jacklin.enums.ProductStatusEnum;
import com.jacklin.utils.EnumUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author:JackLin
 * @Create 2019/3/25 20:22
 */

@Data
@Entity
@DynamicUpdate
public class ProductInfo {

    @Id
    private String productId;

    /**商品名字*/
    private String productName;

    /**价格*/
    private BigDecimal productPrice;

    /**库存*/
    private Integer productStock;

    /**商品描述*/
    private String productDescription;

    /**商品图标*/
    private String productIcon;

    /**商品状态, 0正常 1下架*/
    private Integer productStatus = ProductStatusEnum.UP.getCode(); //默认新增状为在架

    /**类目编号. 商品和类目关系使用类目编号来做关联*/
    private Integer categoryType;

    /**创建时间*/
    private Date createTime;

    /**更新时间*/
    private Date updateTime;

    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum(){
        return EnumUtil.getByCode(productStatus,ProductStatusEnum.class);
    }
}
